#include "Point3d.h"

#include <exception>
#include <utility>
namespace Geometry
  {

  Point3d::Point3d(double i_x, double i_y, double i_z)
    : m_x(i_x), m_y(i_y), m_z(i_z)
    {

    }

  Point3d::Point3d(const Point3d& i_other)
    : m_x(i_other.m_x), m_y(i_other.m_y), m_z(i_other.m_z)
    {

    }

  Point3d::Point3d(Point3d&& i_other)
    {
    _Swap(i_other);
    }
    

  void Point3d::_Swap(Point3d& i_other)    {    std::swap(m_x, i_other.m_x);    std::swap(m_y, i_other.m_y);    std::swap(m_z, i_other.m_z);    }


  Point3d& Point3d::operator=(const Point3d& i_other)
    {
    m_x = i_other.m_x;
    m_y = i_other.m_y;
    m_z = i_other.m_z;
    return *this;
    }

  double Point3d::operator[](size_t i_index) const
    {
    if (i_index > 2)
      {
      throw std::exception("Vector3d operator[]: argument out of range");
      }
    switch (i_index)
      {
      case 0:
        return m_x;
      case 1:
        return m_y;
      case 2:
        return m_z;
      default:
        throw std::exception("Vector3d operator[]: unsupported case");
      }
    }

  }

